<?php
    /**
    * FILE NAME: edit_file.php
    * FUNCTION:  
    *            
    * NOTE:  
    *        
    */
    
        //get your hbc database connection
        include "db_connect.php";
        

        /*********************************************************************************************/

        $cid                     = $_REQUEST['consumer_id'];                //these two vars are from hbcconsumermanagement 
        $fullname                = $_REQUEST['consumer_fullname'];          //page and define the consumer being shown

        /*********************************************************************************************/
        $date                    = $_REQUEST['consumer_date'];
        $nursingfacility         = $_REQUEST['consumer_nursing_facility'];
        $nursingfacilityaddress  = $_REQUEST['consumer_nursing_facility_address'];
        $coordinator             = $_REQUEST['consumer_coordinator'];
        $casenote                = $_REQUEST['consumer_note'];
        $isn                     = $_REQUEST['consumer_isn'];
        $status                  = $_REQUEST['consumer_status'];
        $pageaction              = $_REQUEST['pageaction'];   //defines parameters for the functions below
        /***********************************************************************************************/



        /*---------------------------------------

            handles all EDIT->UPDATE FUNCTIONS 
            with $pageaction var

        -----------------------------------------*/

        if($pageaction=="update"){
         
            /* FULLNAME edited*/
            if($fullname!=""){
             
                $update_file= "UPDATE `hbc_consumers` 
                               SET `hbc_consumers`.`consumer_fullname`='$fullname' 
                               WHERE `hbc_consumers`.`consumer_id`='$cid'";
             
                $queryupdate_file = mysql_query($update_file) or die(mysql_error());
                 
            }

            /* HEIGHT edited*/
            elseif($height!=""){
             
                $updatestyle= "UPDATE `blinds_paidcart` 
                               SET `blinds_paidcart`.`height`='$height' , 
                                   `blinds_paidcart`.`height_inc`='$inc' 
                               WHERE `blinds_paidcart`.`Id`='$line'";

                $queryupdatedorder = mysql_query($updatestyle) or die(mysql_error()); 

            }

            /* EMAIL edited*/
            elseif($email!=""){

                $updatestyle= "UPDATE `blinds_paiduser` 
                               SET `blinds_paiduser`.`email`='$email' 
                               WHERE `blinds_paiduser`.`cart_id`='$Cartid'";
                               
                $queryupdatedorder = mysql_query($updatestyle) or die(mysql_error()); 

            }

            /* NAME edited */
            elseif($name!=""){

                $updatestyle= "UPDATE `blinds_paiduser` 
                               SET `blinds_paiduser`.`name`='$name' 
                               WHERE `blinds_paiduser`.`cart_id`='$Cartid'";
                               
                $queryupdatedorder = mysql_query($updatestyle) or die(mysql_error()); 

            }

            /* COMMENT edited */   
            elseif($comment!=""){

                $updatestyle= "UPDATE `blinds_paiduser` 
                               SET `blinds_paiduser`.`comment`='$comment' 
                               WHERE `blinds_paiduser`.`cart_id`='$Cartid'";
                               
                $queryupdatedorder = mysql_query($updatestyle) or die(mysql_error()); 
 
            }

            /* TELEPHONE edited */
            elseif($telephone!=""){

                $updatestyle= "UPDATE `blinds_paiduser` 
                               SET `blinds_paiduser`.`telephone`='$telephone' 
                               WHERE `blinds_paiduser`.`cart_id`='$Cartid'";

                $queryupdatedorder = mysql_query($updatestyle) or die(mysql_error()); 

            }

            /* ADDRESS edited */
            elseif($address!=""){

                $updatestyle= "UPDATE `blinds_paiduser` 
                               SET `blinds_paiduser`.`address`='$address' , 
                                   `blinds_paiduser`.`city`='$city' , 
                                   `blinds_paiduser`.`state`='$state' , 
                                   `blinds_paiduser`.`zipcode`='$zipcode' 
                               WHERE `blinds_paiduser`.`cart_id`='$Cartid'";
                               
                $queryupdatedorder = mysql_query($updatestyle) or die(mysql_error()); 

            }

            /* SHIP ADDRESS edited */
            elseif($shipaddress!=""){

                $updatestyle= "UPDATE `blinds_paiduser` 
                               SET `blinds_paiduser`.`shipaddress`='$shipaddress' , 
                                   `blinds_paiduser`.`shipcity`='$shipcity' , 
                                   `blinds_paiduser`.`shipstate`='$shipstate' , 
                                   `blinds_paiduser`.`shipzipcode`='$shipzipcode' 
                               WHERE `blinds_paiduser`.`cart_id`='$Cartid'";

                $queryupdatedorder = mysql_query($updatestyle) or die(mysql_error());  

            }
        }//end UPDATE FUNCTIONS

         /*-------------------------------------------------------------------*/
         /**************************** QUERY ONE ******************************/
         /*-------------------------------------------------------------------*/

         /* GETS the CONSUMER RECORD */
         $Select_consumer= "select * 
                           from `hbc_consumers`  
                           where `consumer_id`='$cid'";
         
        /* HOLDS CONSUMER RECORD data */                 
        $Query_consumer = mysql_query($Select_consumer) or die(mysql_error());
        
        $fetch_consumer_info= mysql_fetch_array($Query_consumer);
        
        $cid                     = $fetch_consumer_info['consumer_id'];                //these two vars are from hbcconsumermanagement 
        $fullname                = $fetch_consumer_info['consumer_fullname'];          //page and define the invoice being shown
        $date                    = $fetch_consumer_info['consumer_date'];
        $nursingfacility         = $fetch_consumer_info['consumer_nursing_facility'];
        $nursingfacilityaddress  = $fetch_consumer_info['consumer_nursing_facility_address'];
        $coordinator             = $fetch_consumer_info['consumer_coordinator'];
        $casenote                = $fetch_consumer_info['consumer_note'];
        $isn                     = $fetch_consumer_info['consumer_isn'];
        $status                  = $fetch_consumer_info['consumer_status'];
        $pageaction              = $fetch_consumer_info['pageaction']; 


?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                      "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Home By Choice Consumer Management - Edit Consumer File Page</title>
    <style type="text/css">
        .style11 {color: #FF0000}

        a:hover {
            font-weight: bold;
            background-color: #FFFFA4;
        }

        	#control_panel_banner{
           font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 28px;
           font-weight: bold;
           color: #7B67AA; 
           text-align: center;
           border-top: 1px dashed #674495;
           border-bottom: 1px dashed #674495;
           background-color: #FFBB62; 
        }

	   h2{
           font-family: Verdana, Helvetica, Arial, sans-serif;
           color: #7B67AA; 
           border-top: 1px dashed #674495;
           border-bottom: 1px dashed #674495;
           border-left: 15px solid #EAD170;
           border-right: 15px solid #EAD170;
           background-color: #FFFF9D;
        }
    </style>
    <link href="images/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<table align="center" border="0px" cellpadding="0px" cellspacing="0px" width="780px">
   <tbody>
      <tr>
         <td>
	        <table border="0px" cellpadding="0px" cellspacing="0px" width="10px">
               <tbody>
	              <tr>
                    <td>
		                 <table border="0px" bordercolor="#ffffff" cellpadding="0" cellspacing="0" width="780">
			                 <form name="editcolor" method="get" action="" >
		                        <tbody>
			                        <tr>
				                        <td class="style" colspan="4" style="padding-top:10px;">
                                       <div id="control_panel_banner" >
                                          <H3>EDIT CONSUMER RECORD</H3>
                                       </div>
                                    </td>
				                     </tr>
		                           <tr>
                                    <td bgcolor="#FFFFFF">&nbsp;</td>
                                 </tr>
			                        <tr>
                                    <td colspan="4">
                                       <table width="100%" border="1" cellpadding="10" cellspacing="0" >

                                            <?/////////////////////////////////////////////////////////////////
                                              //                                                             //                                          
                                              //   ACTIONS SELECTED IN THIS FORM PASS UPDATE function VALUES //
                                              //                                                             //
                                              /////////////////////////////////////////////////////////////////
                                             ?>
                                            <form name="editinfo" action="edit_file.php" method="post"> 

                                               <input type="hidden" name="pageaction" value="update">
                                               <input type="hidden" name="consumer_id" value="<?=$cid?>">

					                                <tr>
                                                  <td colspan="2" bgcolor="#FFFF9D">
						                                   <b>Name:&nbsp;</b>
                                                     <? if($change=="fullname"){
                                                           echo"<input type=\"text\" name=\"fullname\" value=\"".$fullname."\" 
                                                                       maxlength=\"45\" size=\"15\">
                                                                <input style=\"font-size:13px; color:black\" 
                                                                       type=\"submit\" name=\"submit\" 
                                                                       value=\"Update\">";
                                                        }else{
                                                           echo"".$fullname."&nbsp;&nbsp;&nbsp;
                                                                <a href=edit_file.php?c_id=$cid&change=fullname>
                                                                   <img src=\"./ico_edit.gif\" border=0>
                                                                </a>"; 
                                                      }?>
                                                   </td>


                                                   <td colspan="2" bgcolor="#FFFF9D">
                                                      <b>Consumer ID:&nbsp;&nbsp;&nbsp;Number&nbsp;</b>
                                                      <? echo"".$cid."&nbsp;";?>
                                                     </td>
                                                  </tr>
			                                           <tr>
                                                       <td colspan="2" bgcolor="#FFFF9D">
                                                          <b>Status:</b>&nbsp;
                                                          <? if($change=="status"){
                                                                 echo"<textarea rows=\"3\" cols=\"35\" name=\"comment\">".$status."</textarea>
                                                                      <input style=\"font-size:13px; color:black\" 
                                                                             type=\"submit\" name=\"submit\" 
                                                                             value=\"Update\">";
                                                             }else{
                                                                 echo"".$status."&nbsp;
                                                                        <a href=edit_file.php?c_id=$cid&change=status>
                                                                            <img src=\"ico_edit.gif\" border=0>
                                                                        </a>"; 
                                                             }?>
                                                        </td>
                                                        <td colspan="2" bgcolor="#FFFF9D">
                                                           <b>HBC Specialist Assigned:&nbsp;</b>
                                                          <? if($change=="coordinator"){
                                                                 echo"<textarea rows=\"3\" cols=\"35\" name=\"comment\">".$coordinator."</textarea>
                                                                      <input style=\"font-size:13px; color:black\" 
                                                                             type=\"submit\" name=\"submit\" 
                                                                             value=\"Update\">";
                                                             }else{
                                                                 echo"".$coordinator."&nbsp;
                                                                        <a href=edit_file.php?c_id=$cid&change=coordinator>
                                                                            <img src=\"ico_edit.gif\" border=0>
                                                                        </a>"; 
                                                             }?>
                                                         </td>
                                                      </tr>
                                                      <tr>
                                                         <td colspan="2" bgcolor="#FFFF9D">
                                                            <b>Intense Service Needs?:&nbsp;</b> 
                                                             <? if($change=="isn"){
                                                                 echo"<textarea rows=\"3\" cols=\"35\" name=\"comment\">".$isn."</textarea>
                                                                      <input style=\"font-size:13px; color:black\" 
                                                                             type=\"submit\" name=\"submit\" 
                                                                             value=\"Update\">";
                                                             }else{
                                                                 echo"".$isn."&nbsp;
                                                                        <a href=edit_file.php?c_id=$cid&change=isn>
                                                                            <img src=\"ico_edit.gif\" border=0>
                                                                        </a>"; 
                                                             }?>
                                                          </td>
                                                         <td colspan="2" bgcolor="#FFFF9D">
                                                            <b>Nursing Facility Residence:&nbsp;</b> 
                                                             <? if($change=="nursingfacility"){
                                                                 echo"<textarea rows=\"3\" cols=\"35\" name=\"comment\">".$nursingfacility."</textarea>
                                                                      <input style=\"font-size:13px; color:black\" 
                                                                             type=\"submit\" name=\"submit\" 
                                                                             value=\"Update\">";
                                                             }else{
                                                                 echo"".$nursingfacility."&nbsp;
                                                                        <a href=edit_file.php?c_id=$cid&change=nursingfacility>
                                                                            <img src=\"ico_edit.gif\" border=0>
                                                                        </a>"; 
                                                             }?>
                                                          </td>
                                                      </tr>
				                                          <tr>
                                                         <td colspan="4" bgcolor="#FFFF9D">
                                                            <b>Nursing Facility Address:&nbsp;</b><br />
                                                            <? if($change=="nursingfacilityaddress"){
                                                                  echo"<input type=\"text\" name=\"email\" value=\"".$nursingfacilityaddress."\" 
                                                                              maxlength=\"45\" size=\"20\">
                                                                       <input style=\"font-size:13px; color:black\" 
                                                                              type=\"submit\" name=\"submit\" 
                                                                              value=\"Update\">";
                                                               }else{
                                                                  echo"".$nursingfacilityaddress."&nbsp;&nbsp;
                                                                       <a href=edit_file.php?c_id=$cid&change=nursingfacilityaddress>
                                                                          <img src=\"ico_edit.gif\" border=0>
                                                                       </a>"; 
                                                               }?>
                                                          </td>
                                                       </tr>
				                                          <tr>
                                                         <td colspan="4" bgcolor="#FFFF9D">
                                                            <b>Latest Case Note:&nbsp;</b><br />
                                                            <? if($change=="casenote"){
                                                                  echo"<input type=\"text\" name=\"email\" value=\"".$casenote."\" 
                                                                              maxlength=\"45\" size=\"20\">
                                                                       <input style=\"font-size:13px; color:black\" 
                                                                              type=\"submit\" name=\"submit\" 
                                                                              value=\"Update\">";
                                                               }else{
                                                                  echo"".$casenote."&nbsp;&nbsp;
                                                                       <a href=edit_file.php?c_id=$cid&change=casenote>
                                                                          <img src=\"ico_edit.gif\" border=0>
                                                                       </a>"; 
                                                               }?>
                                                          </td>
                                                       </tr>
						                                   </form>
                                                 </table>
                                              </td>
                                           </tr>
                                           <tr bgcolor="#ffffff">
                                               <TD bgColor=#ffffff>&nbsp;</TD>
                                           </tr>
							                      <tr bgcolor="#ffffff">
			                                  <tr>
							                         <td colspan="6" align="center" style="padding-top:10px;padding-bottom:10px;">
							                           <b>
                                                   <a href=./hbcconsumermanagement.php>
                                                      Return to HBC Consumer Management Page
                                                   </a>
                                                 </b>
                                              </td>
								                  </tr>
							                    </table>
							                </td>
							            </tr>
							            <tr bgcolor="#ffffff">
							            <tr bgcolor="#ffffff">
							               <td align="center">&nbsp;</td>
							            </tr>
            							<TR bgColor=#FFBB62>
                                                              <TD bgColor=#FFBB62>&nbsp;</TD>
                                                     </TR>
					       </tbody>
				              </form>
			                 </table>
		                   </td>
	                    </tr>
                            <tr>
                                <td bgcolor="#FFFFFF">&nbsp;</td>
                            </tr>
                             <tr>
                                <td bgcolor="#FFFFFF">&nbsp;</td>
                            </tr>
                            <tr>
                              <td><img src="./clip_image002.jpg"></td>
                            </tr>
                     </tbody>
                  </table>
               </td>
            </tr>
         </tbody>
      </table>
   </body>
</html>